#include "TimeCounter.h"

TimeCounter::TimeCounter()
{
    initialTime = 0;
    paused = false;
}
int TimeCounter::Start()
{
    initialTime = SDL_GetTicks();
    return initialTime;
}

void TimeCounter::Pause()
{
    pauseTime = SDL_GetTicks();
    paused = true;
}

void TimeCounter::Stop()
{
    initialTime = 0;
}

void TimeCounter::Resume()
{
    int currentTime = SDL_GetTicks();
    initialTime += (currentTime - pauseTime);
    paused = false;
}

int TimeCounter::GetTime()
{
    if(!paused)
        return SDL_GetTicks() - initialTime;
    else
        return SDL_GetTicks() - pauseTime;
}

int TimeCounter::diff(){
    now = SDL_GetTicks();
    return (initialTime - now);
}
